Links traceability - linksets?

I am grappling a bit with the code sent by Doug Zawacki. If I replace the "TestToReq" and "ProgramUnitsToReq" with the appropriate names of the modules, I don't get the names of the tests (found in objProgramUnit."Object Heading"). I have tried the module name and even included the path to the module (I am opening and subsequently closing the correct modules). However, if I use "*", I do get the names of the test for the modules I want plus all the other in-links.
I suspect that I need to do something with the linkset of the module from which I want the test names. I have tried a number of things but to no avail. What I have now works and is better than before (nothing - manually trace tests to modules), but I was hoping to clean up the output a bit more. Thnak you all for your input and help.

Doug's original code :



pragma runLim, 0
Module mTest = current
Module mReq = read("Req",false)
Module mProgramUnits = read("ProgramUnits",false)

Object objTest,objReq,objProgramUnit

Link lnkTestReq, lnkPuReq

Stream stmReport = write("C:\\temp\\MyReport.txt")

// Loop through all links TEST->Req
for objTest in mTest do
{
stmReport << "Test: " objTest."Object Heading" "\n"

for lnkTestReq in objTest->"TestToReq" do
{
objReq = target(lnkTestReq)
if (null objReq)
continue
if (isDeleted(objReq))
continue

for lnkPuReq in objReq<-"ProgramUnitsToReq" do
{
objProgramUnit= source(lnkPuReq )
if (null objProgramUnit)
continue
if (isDeleted(objProgramUnit))
continue

stmReport << "Covers: " identifier(objProgramUnit) " -- " objProgramUnit."Object Heading" "\n"

}

}
}
close(stmReport)
close(mReq)
close(mProgramUnits)
ack "Done"
SystemAdmin - Fri Mar 06 08:02:17 EST 2009

Re: Links traceability - linksets?
Tony_Goodman - Fri Mar 06 08:12:22 EST 2009

Check these:
1. The module name in the loop is the link module name, not the target or source module name.
2. Module names are case sensitive.
3. Full paths must begin with a forward slash and be from the nearest project ancestor.
4. The source module must be open for in-links to show up, otherwise you have to use LinkRef's and then open the module.

If none of these are the cause then you need to add some debug to find out where the problem is, for example put a count at the beginning of the link loop to count the links.

Re: Links traceability - linksets?
llandale - Sat Mar 07 14:22:30 EST 2009

Yes, the "for lnk in obj <- NameMod" loop presumes the name of the LINK module. Its also quite clumsy, since if you use an unqualified name (e.g. "MyLinkMod"), it only works when that module is in the current folder which is rarely the case for big projects. If you use a fully qualified name (e.g. "/MyProject/MyFolder/MyLinkMod") then the DXL isn't very portable.

The crude version of what I do with links is this; notice it uses "*" in all the link loops, then checks the base unqualified name of the link module, ignoring links it doesn't care about.

// <1> Make sure the source modules I care about is loaded.
ModName_ mnSource, mnLink
LinkRef lref
for lref in obj <- "*" do
{ mnLink = module(lref)
if (name(mnLink) != "MyLinkMod") continue // Don't care about this link
read(fullName(source(lref))
} // end insuring the source module is open
// <2> Now deal with the links
for lnk in obj <- "*"
{ mnLink = module(lnk)
if (name(mnLink) != "MyLinkMod") continue // Not a link I care about
// Deal with this link
}